package com.gardenguell.salad.ui.activity;

import android.os.Build;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.gardenguell.salad.R;
import com.gardenguell.salad.app.HandlerCenter;
import com.gardenguell.salad.data.cache.CacheService;
import com.gardenguell.salad.data.cache.MessageDBManager;
import com.gardenguell.salad.data.client.SaladClient;
import com.gardenguell.salad.data.model.BaseModel;
import com.gardenguell.salad.data.model.Vegetable;
import com.gardenguell.salad.data.volley.OnSuccessResponse;
import com.gardenguell.salad.ui.activity.base.BaseActivity;
import com.gardenguell.salad.ui.activity.base.ToolbarActivity;
import com.gardenguell.salad.ui.adapter.ClickableRecyclerViewAdapter;
import com.gardenguell.salad.ui.adapter.DividerLineDecoration;
import com.gardenguell.salad.ui.adapter.MessageAdapter;
import com.gardenguell.salad.ui.adapter.VegetableAdapter;
import com.gardenguell.salad.ui.fragment.VegetableFragment;
import com.gardenguell.salad.util.DisplayUtil;
import com.gardenguell.salad.util.ResUtil;

import java.util.List;

public class MessageActivity extends ToolbarActivity {


    private RecyclerView mMessageList;


    @Override
    protected int provideContentViewId() {
        return R.layout.activity_message;
    }


    @Override
    public boolean canBack() {
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setToolbarTitle("消息");

        mMessageList = (RecyclerView)findViewById(R.id.message_message_list);

        List<MessageDBManager.Message> data = CacheService.getInstance(this).messageDBManager.getUnReadMessages();
        MessageAdapter messageAdapter = new MessageAdapter(data);


        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this.getBaseContext());
        mMessageList.setLayoutManager(layoutManager);
        // set every item's height is fixed
        mMessageList.setHasFixedSize(true);

        mMessageList.setAdapter(messageAdapter);
        DividerLineDecoration dividerLine = new DividerLineDecoration();
        dividerLine.setSize(DisplayUtil.dip2px(this,3));
        dividerLine.setColor(ResUtil.getColor(R.color.main_background));
        mMessageList.addItemDecoration(dividerLine);

    }


}
